import tester.*;


// runs tests for the buddies problem
public class Examples{
  public Examples(){};
  
  Person ann = new Person("Ann");
  Person bob = new Person("Bob");
  Person cole = new Person("Cole");
  Person dan = new Person("Dan");
  Person ed = new Person("Ed");
  Person fay = new Person("Fay");
  Person gabi = new Person("Gabi");
  Person hank = new Person("Hank");
  Person jan = new Person("Jan");
  Person kim = new Person("Kim");
  Person len = new Person("Len");
 
  ILoBuddy mtlob = new MTLoBuddy();
  
  void initData(){
  	// ann's buddies:
  	ann.addBuddy(bob);
  	ann.addBuddy(cole);
  	
  	// bob's buddies:
  	bob.addBuddy(ed);
  	bob.addBuddy(ann);
  	bob.addBuddy(hank);
  	
  	// cole's homies
  	cole.addBuddy(dan);
  	
  	// dan's peeps
  	dan.addBuddy(cole);
  	
  	// ed's lone buddy
  	ed.addBuddy(fay);
  	
  	// fay has some buddies.
  	fay.addBuddy(ed);
  	fay.addBuddy(gabi);
  	
  	//gabi
  	gabi.addBuddy(ed);
  	gabi.addBuddy(fay);
  	
  	//poor hank.
  	
  	// JAN!
  	jan.addBuddy(kim);
  	jan.addBuddy(len);
  	
  	// kim.
  	kim.addBuddy(jan);
  	kim.addBuddy(len);
  	
  	//len
  	len.addBuddy(jan);
  	len.addBuddy(kim);
  }
  
  void tearDown(){
  	ann.removeAll();
  	bob.removeAll();
  	cole.removeAll();
  	dan.removeAll();
  	ed.removeAll();
  	fay.removeAll();
  	gabi.removeAll();
  	hank.removeAll();
  	jan.removeAll();
  	kim.removeAll();
  	len.removeAll();
  }
  
  @TestMethod
  void testAdd(Tester t){
  	// SETUP:
  	initData();
  	
  	hank.addBuddy(ann);
  	
  	// TEST:
  	t.checkExpect(hank.buddies, new ConsLoBuddy(ann, this.mtlob));
  	
  	// TEAR DOWN:
  	tearDown();
  }
  
  @TestMethod
  void testHasDirect(Tester t){
    // SETUP:
    initData();
    
    // TEST:
    t.checkExpect(bob.hasDirectBuddy(ann), true);
    t.checkExpect(bob.hasDirectBuddy(len), false);
    
    // TEAR DOWN:
    tearDown();
  }
  
  @TestMethod
  void testCounting(Tester t){
    // SETUP:
    initData();
    
    // TEST:
    t.checkExpect(bob.countCommonBuddies(hank), 0);
    t.checkExpect(bob.countCommonBuddies(fay), 1);
    
    // TEAR DOWN:
    tearDown();
  }
  
  @TestMethod
  void testHasDistant(Tester t){
    // SETUP:
    initData();
    
    // TEST:
    t.checkExpect(bob.hasDistantBuddy(cole), true);
    t.checkExpect(bob.hasDistantBuddy(ed), true);
    t.checkExpect(bob.hasDistantBuddy(len), false);
    
    // TEAR DOWN:
    tearDown();
  }
  
  @TestMethod
  void testPartyCount(Tester t){
    // SETUP:
    initData();
    
    // TEST:
    t.checkExpect(jan.partyCount(), 3);
    t.checkExpect(hank.partyCount(), 1);
    
    // TEAR DOWN:
    tearDown();
  }
  
} 